CREATE TABLE [dbo].[LicenseUser]
(
[LicenseKey] [uniqueidentifier] NOT NULL,
[UserKey] [uniqueidentifier] NOT NULL,
[CreatedByUserKey] [uniqueidentifier] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[MarkedForDeleteOn] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LicenseUser] ADD CONSTRAINT [PK_LicenseUser] PRIMARY KEY CLUSTERED ([LicenseKey], [UserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LicenseUser_CreatedByUserKey] ON [dbo].[LicenseUser] ([CreatedByUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LicenseUser_UserKey] ON [dbo].[LicenseUser] ([UserKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LicenseUser] ADD CONSTRAINT [FK_LicenseUser_License] FOREIGN KEY ([LicenseKey]) REFERENCES [dbo].[License] ([LicenseKey])
GO
ALTER TABLE [dbo].[LicenseUser] ADD CONSTRAINT [FK_LicenseUser_UserMain] FOREIGN KEY ([UserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[LicenseUser] ADD CONSTRAINT [FK_LicenseUser_UserMain_CreatedBy] FOREIGN KEY ([CreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO